home *** CD-ROM | disk | FTP | other *** search
- Path: sun001.spd.dsccc.com!spd!jmccarty
- From: jmccarty@spd.dsccc.com (Mike McCarty)
- Newsgroups: comp.lang.c
- Subject: Re: Watch out! C "gotcha!"
- Date: 15 Feb 1996 19:38:01 GMT
- Organization: DSC Communications Corporation, Plano, Texas USA
- Message-ID: <4g022p$hkc@sun001.spd.dsccc.com>
- References: <4fthhh$7th@blackice.winternet.com> <3122762F.6587@oc.com>
- NNTP-Posting-Host: aplo139.spd.dsccc.com
-
- In article <3122762F.6587@oc.com>, Larry Weiss <lfw@oc.com> wrote:
- )Michael Schwarz wrote:
- ) >
- ) > Many of you may already know this, but even after ten years of coding
- ) > in C, this took my by surprise at first. A co-worker and I were looking
- ) > at some library C code where I work and we noticed that the "default"
- ) > clause of one of the switches was misspelled as "defalt."
- ) > ...
- ) > The thing that scares me the most about this is that either I've never before
- ) > made this particular mistake or for the last ten years I've been leaving
- ) > behind a number of ticking code bombs...
- ) >
- ) > I invite your comments on this (and your knowledge -- I'm a good C programmer
- ) > but I don't write compilers and I'm not fully conversant with the full
- ) > ANSI spec on C). Please feel free to e-mail me.
- ) >
- )
- )
- )It's a good observation. I'd suggest a
- )
- ) grep "t:" *.c | grep -v "default"
- )
- )or equivalent inspection of any body of C source every once in a while.
-
-
- Perhaps just ":" would be better. But of course, someone, somewhere, is
- putting the colons on the next line.
-
- The really only truly way to watch for this is to use a language which
- forces declaration of labels. And does =not= use a label construct for
- multiway jump or case statement (C does not have a true case statment,
- it has a multiway jump).
-
- Mike
- ----
- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-
- I don't speak for DSC. <- They make me say that.
-